package zhoufy;

import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA by ChouFy on 2020-05-10.
 *
 * @author chouFy
 */
public class DubboMain {

    public static void main(String[] args) throws IOException {

        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);


        context.start();

        while(true) {
            Scanner ca = new Scanner(System.in);
            String s = ca.nextLine();
            System.out.println(s);
        }

    }

    @Configuration
    @EnableDubbo(scanBasePackages = "com.zhoufy.service.impl")
    @PropertySource("classpath:/dubbo-provider.properties")
    static class ProviderConfiguration {
        @Bean
        public RegistryConfig registryConfig() {
            RegistryConfig registryConfig = new RegistryConfig();
            registryConfig.setAddress("zookeeper://localhost:2181");
            return registryConfig;
        }


    }
}
